Moderators:PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange
Forum rules DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
I'm trying to extract images without rerendering, from an pdf document, where each page contains just one image. The idea is just save the image (which is possible in the pdfXChangeEditor using the content bar) and not using ""op.document.exportToImages" which does (from what I saw) some new rendering and so some quality lossesw.
But that did not work, I got an exception for every defined PXC_ImageDataType. From the ImageData I hope it ios possiple to create a bitmap which could be exported.
private void ExportImage(PDFXEdit.IPXV_Inst Inst, PDFXEdit.IPXV_Document Doc)
{
int nSelID = Inst.Str2ID("selection.contentItems", false);
uint nPage = 0; //Page number that will have it's image content item exported
//First we need to create content items selection
PDFXEdit.IPXV_ContentItemsSelection itSel = (PDFXEdit.IPXV_ContentItemsSelection)Doc.CreateStdSel((uint)nSelID);
//Then we need to get root item entry for the desired page (we'll create it if needed)
PDFXEdit.IPXV_ContentItemEntry itEntry = itSel.GetSel(nPage, true);
//Inserting needed content items from the page
var content = Doc.CoreDoc.Pages[nPage].GetContent(PDFXEdit.PXC_ContentAccessMode.CAccessMode_Readonly);
if (GetFirstImageOnPage(content, ref itEntry) == false)
return;
int nID = Inst.Str2ID("op.document.extractImage", false);
PDFXEdit.IOperation Op = Inst.CreateOp(nID);
var input = Op.Params.Root["Input"];
input.Add().v = Doc.CoreDoc;
PDFXEdit.ICabNode options = Op.Params.Root["Options"];
//Adding selected page's root entry with added image content item to the operation
options["Entry"].v = itEntry;
//Setting resulting png file name
options["FileName"].v = @"D:\Image_res.png";
//Setting whether the image should be extracted visually or as it is in the PDF content
options["ExtractVisually"].v = false;
//Extracting image content item
Op.Do();
//Clearing the selection
itSel.Clear();
}