Barcode 39 does not render correct when printing

A forum for questions or concerns related to the PDF-XChange Core API SDK

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

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.
ErikG
User
Posts: 6
Joined: Sun Mar 22, 2009 8:59 pm

Barcode 39 does not render correct when printing

Post by ErikG »

Hello!
We have used pxcview.dll for years (more than 5) to print pdf on user computers. We have only had a few issues where printing have gone wrong, so I am evaluating the latest build (from PDFXChange PRO bulid 5.5.315.0). This solves the issues, but another comes up instead: barcode printing is not rendering correct any more (on OneNote or PDF-XChange printer driver). It works om my nearest printer, but I want to make sure it will work on every printer. I enclose a few samples.
You do not have the required permissions to view the files attached to this post.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17949
Joined: Mon Jan 12, 2009 8:07 am
Location: London

Re: Barcode 39 does not render correct when printing

Post by Tracker Supp-Stefan »

Hello ErikG,

Can you please send us all the printing parameters that you are using?

Regards,
Stefan
ErikG
User
Posts: 6
Joined: Sun Mar 22, 2009 8:59 pm

Re: Barcode 39 does not render correct when printing

Post by ErikG »

We are using this code. Mostly borrowed from your example.

/* PrintPdfDocumentWithPDFXChange.cpp */
#include "stdafx.h"
#include "PrintPdfDocumentWithPDFXChange.h"
#include "pxcview36.h"
#include "WMSetDefaultPrinter.h"
#include "ErrorHandlingRoutines.h"


#define IS_DS_FAILED(x) (((x) & 0x80000000) != 0)
#define LICENSEID "Removed"
#define UNLOCKCODE "Removed"
enum PXCVA_Flags
{
PXCVA_NoApply = 0x00000001,
PXCVA_NoUI = 0x00000002,
PXCVA_GetNamed = 0x00000004
};

HRESULT PrintPdfDocumentWithPDFXChange2(const char* pFileName, const char* printer) {
HRESULT hr;
PXVDocument pDoc = NULL;
LPCSTR Key = LICENSEID;
LPCSTR DevCode = UNLOCKCODE;
CString FileName = pFileName;
USES_CONVERSION;
LPCWSTR wFilename = A2W(FileName);
DWORD page_num = 0;
DWORD i;
PXV_CommonRenderParameters pParams;
HDC hDC;
DOCINFO doc_info;
LONG angle;
double width;
double height;

char szPrinterName[_MAX_PATH];
DWORD pdwBufferSize=sizeof(szPrinterName);
RECT WholePageRect;

if (printer != NULL && strlen(printer) > 0)
hDC = CreateDC("WINSPOOL", printer, NULL, NULL);
else {
// Get a printer DC
DPGetDefaultPrinter( szPrinterName, &pdwBufferSize);
hDC = CreateDC("WINSPOOL", szPrinterName, NULL, NULL);
}

if (hDC == NULL) {
WriteToLogFile (3, "PrintPdfDocumentWithPDFXChange: Can not create printer");
return -300;
}

pParams.WholePageRect = &WholePageRect;
int ix, iy;
ix = GetDeviceCaps(hDC,LOGPIXELSX);
iy = GetDeviceCaps(hDC,LOGPIXELSY);
int printResX = GetDeviceCaps(hDC,HORZRES);
int printResY = GetDeviceCaps(hDC,VERTRES);
int printMaxX = GetDeviceCaps(hDC,HORZSIZE);
int printMaxY = GetDeviceCaps(hDC,VERTSIZE);
int offsetX = GetDeviceCaps(hDC,PHYSICALOFFSETX);
int offsetY = GetDeviceCaps(hDC,PHYSICALOFFSETY);
WholePageRect.bottom = printResY;
WholePageRect.top = 0;
WholePageRect.left = 0;
WholePageRect.right = printResX;
pParams.DrawRect = NULL;
pParams.RenderTarget = pxvrm_Printing;
pParams.Flags = pxvrpf_UseVectorRenderer;

if (IS_DS_FAILED(hr = PXCV_Init(&pDoc,Key,DevCode)))
return hr;
if (IS_DS_FAILED(hr = PXCV_ReadDocumentW(pDoc,wFilename,0)))
return hr;
if (IS_DS_FAILED(hr = PXCV_GetPagesCount(pDoc,&page_num)))
return hr;

// Start a printer job
memset(&doc_info, 0, sizeof(doc_info));
doc_info.cbSize = sizeof(doc_info);
doc_info.lpszDocName = _T(pFileName);
StartDoc(hDC, &doc_info);
for (i=0; i<page_num; i++) {
StartPage(hDC);
if (IS_DS_FAILED(hr = PXCV_GetPageRotation(pDoc,i,&angle))) {
DeleteDC(hDC);
PXCV_Delete(pDoc);
return hr;
}
if (IS_DS_FAILED(hr = PXCV_GetPageDimensions(pDoc,i,&width,&height))) {
DeleteDC(hDC);
PXCV_Delete(pDoc);
return hr;
}
if (angle == 0 && width > height)
pParams.Flags = pxvrpf_UseVectorRenderer | pxvrpf_Rotate_Rotate90CCW;
else
pParams.Flags = pxvrpf_UseVectorRenderer;
if (IS_DS_FAILED(hr = PXCV_DrawPageToDC(pDoc,i,hDC,&pParams))) {
DeleteDC(hDC);
PXCV_Delete(pDoc);
return hr;
}
PXCV_ReleasePageCachedData(pDoc,i,pxvrcd_ReleaseDocumentImages | pxvrcd_ReleaseDocumentFonts);
PXCV_ReleaseCachedData(pDoc,pxvrcd_ReleaseDocumentFonts);
EndPage(hDC);
}

EndDoc(hDC);
DeleteDC(hDC);
PXCV_Delete(pDoc);

return 0;
}

HRESULT PrintPdfDocumentWithPDFXChange(const char* pFileName, const char* printer) {

HRESULT hr = PrintPdfDocumentWithPDFXChange2(pFileName, printer);
if (IS_DS_FAILED(hr)) {
char Message[1000];
PXCV_Err_FormatErrorCode(hr,Message,1000);
WriteToLogFile (3, "Error in PrintPdfDocumentWithPDFXChange:");
WriteToLogFile (3, Message);
PXCV_Err_FormatFacility(hr,Message,1000);
WriteToLogFile (3, Message);
}

return 0;
}
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17949
Joined: Mon Jan 12, 2009 8:07 am
Location: London

Re: Barcode 39 does not render correct when printing

Post by Tracker Supp-Stefan »

Hello ErikG,

Thanks for the code.
Can you please try to remove the pxvrpf_UseVectorRenderer flag? Your output is image based anyway - so this is not needed, and might allow you to generate the correct PDF files.

Regards,
Stefan
ErikG
User
Posts: 6
Joined: Sun Mar 22, 2009 8:59 pm

Re: Barcode 39 does not render correct when printing

Post by ErikG »

Hello Stefan!
I am sorry, but removing the pxvrpf_UseVectorRenderer did not work. Only change was that colors were replaced by grayscale. I have a small testbench which just pick up the pdf and sends it to my print routine, so I am certain that nothing else is interfering.
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3550
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada

Re: Barcode 39 does not render correct when printing

Post by Ivan - Tracker Software »

Can you please add flag pxvrpf_EmbeddedFontAsCurves to the pParams.Flags ?
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
ErikG
User
Posts: 6
Joined: Sun Mar 22, 2009 8:59 pm

Re: Barcode 39 does not render correct when printing

Post by ErikG »

Hello Ivan and thanks for your prompt reply.

Only adding pxvrpf_EmbeddedFontAsCurves to pParams.Flags did not do the trick. The color came back, but the document went black See test 1. But when I combined that flag with pxvrpf_UseVectorRenderer as in

pParams.Flags = pxvrpf_UseVectorRenderer | pxvrpf_EmbeddedFontAsCurves;

I got what I wanted! :D. See test 2.
You do not have the required permissions to view the files attached to this post.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17949
Joined: Mon Jan 12, 2009 8:07 am
Location: London

Re: Barcode 39 does not render correct when printing

Post by Tracker Supp-Stefan »

Hi Erik,

Glad to hear you got the desired result!

Cheers,
Stefan