What's New in Documents for PDF v2
GcPDF v2 Service Pack 2 - June 12, 2019
Render PDF to Images
When PDF files are distributed among clients or stakeholders, there are certain changes that need to be pointed out, like text changes, marking certain other areas for additional info. Certain PDF pages provide important info, that needs to be used on web pages, word processing documents, or Powerpoint presentations.
In addition to converting PDFs to image formats, you also need to see the image output quality, and whether the formatting will be altered during conversion. Unfortunately, many online PDF to image converter tools aren't great at retaining this quality.
GcPdf adds the support of saving PDFs to images without losing quality. Until now, GcPdf provided the capability to extract images from PDF. However, PDF to image conversion will now be a direct conversion with minimal lines of code through new additions to the API.
GcPdf provides two ways of saving PDFs to images:
-
Using SaveAs methods - GcPdfDocument now supports direct methods to save PDF to Image formats. Use GcPdfDocument.SaveAsBmp(..), SaveAsPng(..), SaveAsGif(), SaveAsJpeg(..), SaveAsTiff(..), .SaveAsJpeg(..) methods. Just provide the file names, and the PDF document will be saved as Images. These methods are supported for JPEG, TIFF, GIF, PNG, and BMP image formats.
-
Render specific PDF pages or a mix of PDF pages to Images - You can draw PDF pages on the image graphics using page.Draw(..) method, or if your PDF pages contain annotations, you can draw the PDF page annotations on the graphics object using page.DrawAnnotations(..) method. Once drawn on the graphics, just save the bitmap image in any image format. This method will work when GcPdf is used with our other Document API - GrapeCity Documents for Imaging. To implement this, you'll need a license for both GcPdf and GcImaging.
- Save PDF Page directly as an image - You can also save a PDF page directly as image using page.SaveAsBmp(..), SaveAsPng(..), SaveAsGif(), SaveAsJpeg(..), SaveAsTiff(..), .SaveAsJpeg(..) methods.
Redact Annotation
Redaction is important to hide certain confidential information before it's distributed over the web or printed. Since a PDF is not editable, redaction becomes important to hide the content that is not supposed to be shared. The process should highlight/mark the information to be hidden on the PDF.
With the new service pack, GcPdf adds RedactAnnotation to its list of supported Annotation types to mark instances of text as redaction. With GcPdf, you can find all instances of text like a password, SSN, name, address (or some other sensitive info) and mark the content for redaction. People in charge of redaction can then open the PDF with those marks in Acrobat Reader to see what has been found/marked and apply the redactions.
With GcPdf, the redactions can be of any kind, (you can not only wipe out the content with color, but you can also add images, or provide a replacement text and render on that location). This can be difficult to do through a UI in Acrobat.
Import/Export FDF/XFDF Data
PDFs are now popularly displayed on the web. When PDFs contain Forms, and then after being filled up, the Form data is transferred over the web as FDF/XFDF file formats. When data is transferred over the web, these FDF/XFDF files can help populate a database or PDF Form of some other PDF. The advantages of an FDF/XFDF file are - it occupies less space, since it contains just form data rather than the PDF file itself, and the other is that many PDF viewers do not allow a user to save a filled PDF form, so the form is exported and saved to an FDF/XFDF format.
With the new service pack, it will now also be possible to import/export FDF/XFDF form data through GcPdf. GcPdf adds simple methods to import/export data from FDF/XFDF formats.
- GcPdfDocument.ExportFormDataToFDF(...)
- GcPdfDocument.ExportFormDataToXFDF(...)
- GcPdfDocument.ImportFormDataFromFDF(...)
- GcPdfDocument.ImportFormDataFromXFDF(...)
See more details below for the implementation.
Import/Export PDF form Data to/from XML
PDF Forms are also submitted as XML files from some applications. It's a plain text format (most applications prefer this format for storing and sharing data, as well as being a common information exchange format). With the new service pack, GcPdf will also support import/export of XML data into and from Forms.
- GcPdfDocument.ExportFormDataToXML(...)
- GcPdfDocument.ImportFormDataFromXML(...)
Remove Signatures and Signature Field from PDF
Do you have a template, but fail to re-use it because of a signature? You can now re-use a signed PDF template, by removing the signatures, and keeping the Signature Field, or simply remove the Signature Field. Just delete the SignatureField from a list of Form fields and set its value to null, or remove the field.
GcPDF v2 Service Pack 1 - January 30, 2019
New feature: SoftMask to draw transparent elements on PDFs
GcPdfGraphics introduces SoftMask feature, which allows you to create a mask with a FormXObject; draw on that object's Graphics using any supported drawing methods (including semi-transparent drawing), and then use the result as a mask when drawing on the document's pages. This feature can help you specify images that have transparent content on a PDF document:
Text outlining and filling
Sometimes you may not need to display the text in forecolor, but instead, display the outline of the text. You may just outline the text and not fill it in, or you need to outline a text in different color and fill in the text with some background color. With GcPdf Service Pack 1, you can apply font outlining with:
- Single outline color
- Double outline
- Gradient color
- Shadows
Include horizontal text fragments in vertical text
You can now render horizontal characters vertically without rotation, a use case that would mostly be for rendering Chinese, Japanese, or Korean vertical text. Features supported are:
- TextFormat allows you to specify the character orientation in vertical text blocks using SidewaysInVerticalText and UprightInVerticalText properties
- Latin (ASCII) letters are automatically rendered horizontally in vertical text ("Tate chu yoko")
- You can now output several horizontal characters together (without line breaks) in vertical text (TextFormat.TextRunAsCluster)
Add sound annotations to PDF files
GcPdf supports several annotation types and now it adds another to the list: sound annotations! This support can make your PDF documents more interactive. Sound annotations can be applied on a form action or describe particular parts of PDF documents. This annotation has a sound object associated with it recorded from the computer's microphone or from a file.
Support specific page-level navigation
This support adds specific page navigation features to PDF documents, including the ability to add page labels to pages so that PDF viewers would show a page label (e.g. 'Preface iii') instead of the generic 'Page 3.' The feature supports all features as mentioned in the PDF Specification 1.7 Chapter 8.3.
Extract a list of fonts used in a PDF document
You can now extract a list of fonts used in a PDF so you can use the PDF on a different system or reuse the fonts for a different PDF file. The list includes fonts with their properties from PDF documents. Simply load a PDF document in the GcPdfDocument object, and use the GetFonts() method:
using (var fs = new FileStream(Path.Combine("Resources", "PDFs", sourcePDF), FileMode.Open, FileAccess.Read)) {
var doc1 = new GcPdfDocument();
doc1.Load(fs);
var fonts = doc1.GetFonts();
}
Support for all PDF/A conformance levels
GcPdf has been supporting saving PDF documents to PDF/A. With GcPdf, you can now create, edit, and save PDF/A documents of all conformance levels.
The support also includes the Associated Files concept, which is needed to support embedded files in PDF/A-3 documents. You can embed files, images, txt, docx files, and more, and associate them with document elements. PDF/A-3a requires all content to be tagged, so you can add elements tagged as per PDF/A rules in the PDF/A documents.
Extract data from PDF files from a specific position
If you need to use data from specific parts of a PDF file, you can extract text from any position on the page. You'll be able to fetch data from PDF documents based on geometry and use this data in any other documents like TXT, DOCX, XLSX.
Format text as Subscript or Superscript in PDF
You can now add text like mathematical equations, chemical formulas, trademarks, or copyright to your PDFs using GcPdf. Add these simple boolean properties to the TextFormat class, and you can set text to superscript or subscript in just a single line of code.
For a full list of bug fixes, visit the Release Notes
GcPDF 2.0 - December 5, 2018
Tagged PDF (PDF/UA)
Tagged content enables screen reader software and other assistive technologies to read PDFs. Users can create and load PDF/UA compliant files, and create, load, modify and modify tags in existing PDFs.
StructElement seParagraph = new StructElement("P");
seParagraph.DefaultPage = page;
// add it to Part element
sePart.Children.Add(seParagraph);
// draw TextLayout within tagged content
g.BeginMarkedContent(new TagMcid("P", i));
g.DrawTextLayout(tl, new _Point(20, y));
g.EndMarkedContent();
// add content item to paragraph StructElement
eParagraph.ContentItems.Add(new McidContentItemLink(i));
Merge, split, copy, and move pages between PDF documents
A key PDF editing feature has been added! Users can now merge multiple PDF documents into a single document; split up a PDF into multiple documents, and copy and move pages within a PDF or between PDFs. Additionally, a FormXObject, a space-efficient way to store repetitive content, can be created from any PDF page and reused in the same or other documents.
GcPdfDocument doc = new GcPdfDocument();
using (var fs0 = new FileStream(Path.Combine("Resources", "PDFs", "The-Rich-History-of-JavaScript.pdf"), FileMode.Open, FileAccess.Read))
using (var fs1 = new FileStream(Path.Combine("Resources", "PDFs", "CompleteJavaScriptBook.pdf"), FileMode.Open, FileAccess.Read))
{
doc.Load(fs0);
// Save page count for the navigation link added below:
var pgNo = doc.Pages.Count;
var doc1 = new GcPdfDocument();
doc1.Load(fs1);
doc.MergeWithDocument(doc1, new MergeDocumentOptions());
Draw images semi-transparently
GcPdf has always supported popular formats for drawing images. Semi-transparent images enhance this feature to include watermark logos and images.
Document-level file attachments
GcPDF 1.0 enabled users to add file attachments as annotations to PDF documents, which pointed at document locations in the system. Now, GcPdf adds the ability to actually embed these files of different formats in PDF. Once PDF is generated, you can open these files from the PDF itself.
Extract images from PDF
Extract any image from a PDF file with this new feature! Images can be saved for uploading online or to the system, and use the images in different file formats.
var docSrc = new GcPdfDocument();
docSrc.Load(fs);
var imageInfos = docSrc.GetImages();
Extract text from PDF
When users need to edit a PDF but don't have a PDF tool, they can now extract all text from the PDF for use on web pages, Word documents, PowerPoint, etc.
var doc1 = new GcPdfDocument();
doc1.Load(fs);
// Get the texts of the loaded document's pages:
var texts = new List<string>();
doc1.Pages.ToList().ForEach(p_=? texts.Add(p_.GetText()));
Updates
- Render PDF to Images
- Redact Annotation
- Import/Export FDF/XFDF Data
- Import/Export PDF form Data to/from XML
- Remove Signatures and Signature Field from PDF
- New feature: SoftMask to draw transparent elements on PDFs
- Text outlining and filling
- Include horizontal text fragments in vertical text
- Add sound annotations to PDF files
- Support specific page-level navigation
- Extract a list of fonts used in a PDF document
- Support for all PDF/A conformance levels
- Extract data from PDF files from specific position
- Format text as Subscript or Superscript in PDF
- Tagged PDF (PDF/UA)
- Merge, split, copy, and move pages between PDF documents
- Draw images semi-transparently
- Document-level file attachments
- Extract images from PDF
- Extract text from PDF
Related Links