logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

New Topic Post Reply
Options
Go to last post Go to first unread
adammckay  
#1 Posted : Wednesday, June 22, 2022 3:57:56 PM(UTC)
Quote
adammckay

Rank: Newbie

Groups: Registered
Joined: 6/22/2022(UTC)
Posts: 3
United States
Location: Pennsylvania

We are using the Pdfium.NET SDK in a VB.NET solution. I have worked out the code to load Initilize and load a PDF document from disk. The Resulting PDF object has a lot of obvious properties like Author, Subject, etc. that are easy to access. I do not see any properties or methods to detect if the document is linearized. For that matter, I see nothing to check if the document is a PDFA. I read and searched the SDK. I see that there is an AccessiblityProvider to check for linearization but it seems to only exist for new documents. It is not clear what that is for and how to use it (if that's even the right direction here). As for PDFA, I can find nothing.

Any help would be appreciated.
Paul Rayman  
#2 Posted : Thursday, June 23, 2022 8:24:57 AM(UTC)
Quote
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,027

Thanks: 5 times
Was thanked: 122 time(s) in 119 post(s)
Hi,

There is no property for check for FPDFA. The Pdf Availability Provider must be used to check the linearization. Here is an example of how to load an existing PDF document into a PDF viewer using the PdfAvailabilityProvider class.

Code:

string pathToPdf = @"e:\0\1gb\test_big.pdf";
PdfCommon.Initialize();
var pdfFile = System.IO.File.OpenRead(pathToPdf);
var provider = new PdfAvailabilityProvider((int)new System.IO.FileInfo(pathToPdf).Length);
provider.AddSegment += (sender, e) =>
{
};
provider.IsSegmentAvailable += (sender, e) =>
{
	e.IsSegmentAvailable = true;
};
provider.ReadSegment += (sender, e) =>
{
	pdfFile.Seek(e.SegmentOffset, System.IO.SeekOrigin.Begin);
	pdfFile.Read(e.DstBuffer, 0, e.SegmentSize);
	e.IsSuccess = true;
};

var linstate = provider.IsLinearized;

while (!provider.IsDocumentAvailable) ;
provider.CreateDocument();

while (provider.IsFormAvailable == Patagames.Pdf.Enums.IsFormAvailableResults.NotAvaialble) ;
var forms = provider.IsFormAvailable == IsFormAvailableResults.Available ? new PdfForms() : null;

provider.InitDocument(forms);
pdfViewer1.Document = provider.Document;


After calling PdfViewer.CloseDocument() or setting the pdfviewer1.Document property to null, you also need to dispose the provider and close the file.

Code:
pdfViewer1.CloseDocument(); // or pdfViewer1.Document = null;
provider.Dispose();
pdfFile.Close();

Edited by user Thursday, June 23, 2022 8:26:17 AM(UTC)  | Reason: Not specified

Quick Reply Show Quick Reply
Users browsing this topic
New Topic Post Reply
Forum Jump  
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.