Print Page | Close Window

Copy images from pdf file to another pdf file

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3461
Printed Date: 29 Mar 24 at 11:52AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Copy images from pdf file to another pdf file
Posted By: emgi
Subject: Copy images from pdf file to another pdf file
Date Posted: 17 May 17 at 9:11PM
I would like to copy the images from one file to another.
To do this, I use DPLGetImageListItemDataToString and DPLAddImageFromString But DPLAddImageFromString returns systematically 0 regardless of the image What is wrong?

int docid = DPLLoadFromFileA(pdflib, "file.pdf","");
int res = DPLSelectPage(pdflib, page);
int ilid = DPLGetPageImageList(pdflib, 0);
int imageCount = DPLGetImageListCount(pdflib, ilid);
int ndocid = DPLNewDocument(pdflib);

for (int i = 0; i < imageCount; i++)
{
DPLSelectDocument(pdflib, docid);
DPLSelectPage(pdflib, page);
char *tmp = DPLGetImageListItemDataToString(pdflib, ilid, i + 1, 0);
double left = DPLGetImageListItemDblProperty(pdflib, ilid, i + 1, 501);
double top = DPLGetImageListItemDblProperty(pdflib, ilid, i + 1, 502);
double width = DPLGetImageListItemDblProperty(pdflib, ilid, i + 1, 503) - DPLGetImageListItemDblProperty(pdflib, ilid, i + 1, 501);
double height = DPLGetImageListItemDblProperty(pdflib, ilid, i + 1, 502) - DPLGetImageListItemDblProperty(pdflib, ilid, i + 1, 508);
DPLSelectDocument(pdflib, ndocid);
DPLSelectPage(pdflib, 1);
int imageId = DPLAddImageFromString(pdflib, tmp, 0);
DPLSelectImage(pdflib, imageId);
int res = DPLDrawImage(pdflib, left, top, width, height);
}
DPLCompressContent(pdflib);
DPLSaveToFileA(pdflib,"D:\\file2.pdf");
...

Regards





Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk