<?xml version="1.0"?>
<ownershipDocument>

    <schemaVersion>X0303</schemaVersion>

    <documentType>4</documentType>

    <periodOfReport>2010-12-31</periodOfReport>

    <issuer>
        <issuerCik>0000102212</issuerCik>
        <issuerName>UNIVEST CORP OF PENNSYLVANIA</issuerName>
        <issuerTradingSymbol>UVSP</issuerTradingSymbol>
    </issuer>

    <reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0001415199</rptOwnerCik>
            <rptOwnerName>SCHWEITZER JEFFREY M</rptOwnerName>
        </reportingOwnerId>
        <reportingOwnerAddress>
            <rptOwnerStreet1>3964 GOSHEN DRIVE</rptOwnerStreet1>
            <rptOwnerStreet2></rptOwnerStreet2>
            <rptOwnerCity>HARLEYSVILLE</rptOwnerCity>
            <rptOwnerState>PA</rptOwnerState>
            <rptOwnerZipCode>19438</rptOwnerZipCode>
            <rptOwnerStateDescription></rptOwnerStateDescription>
        </reportingOwnerAddress>
        <reportingOwnerRelationship>
            <isDirector>0</isDirector>
            <isOfficer>1</isOfficer>
            <isTenPercentOwner>0</isTenPercentOwner>
            <isOther>0</isOther>
            <officerTitle>EVP &amp; CFO</officerTitle>
        </reportingOwnerRelationship>
    </reportingOwner>

    <nonDerivativeTable>
        <nonDerivativeTransaction>
            <securityTitle>
                <value>COMMON</value>
            </securityTitle>
            <transactionDate>
                <value>2010-12-31</value>
            </transactionDate>
            <deemedExecutionDate>
                <value>2011-01-05</value>
            </deemedExecutionDate>
            <transactionCoding>
                <transactionFormType>4</transactionFormType>
                <transactionCode>F</transactionCode>
                <equitySwapInvolved>0</equitySwapInvolved>
            </transactionCoding>
            <transactionAmounts>
                <transactionShares>
                    <value>102</value>
                    <footnoteId id="F1"/>
                </transactionShares>
                <transactionPricePerShare>
                    <value>19.17</value>
                </transactionPricePerShare>
                <transactionAcquiredDisposedCode>
                    <value>D</value>
                </transactionAcquiredDisposedCode>
            </transactionAmounts>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>8953.843</value>
                    <footnoteId id="F2"/>
                    <footnoteId id="F3"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value></value>
                </natureOfOwnership>
            </ownershipNature>
        </nonDerivativeTransaction>
        <nonDerivativeHolding>
            <securityTitle>
                <value>COMMON</value>
            </securityTitle>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>8953.843</value>
                    <footnoteId id="F2"/>
                    <footnoteId id="F3"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value></value>
                </natureOfOwnership>
            </ownershipNature>
        </nonDerivativeHolding>
    </nonDerivativeTable>

    <footnotes>
        <footnote id="F1">VESTED SHARES USED TO PAY TAXES</footnote>
        <footnote id="F2">DOES INCLUDE 537.8430 SHARES ACQUIRED ON OR AFTER AUGUST 15, 1996 THROUGH THE DIVIDEND REINVESTMENT PLAN AND EMPLOYEE STOCK PURCHASE PLAN.</footnote>
        <footnote id="F3">DOES INCLUDE 6,949 SHARES OF RESTRICTED STOCK.</footnote>
    </footnotes>

    <remarks></remarks>

    <ownerSignature>
        <signatureName>Jeffrey M. Schweitzer</signatureName>
        <signatureDate>2011-01-04</signatureDate>
    </ownerSignature>
</ownershipDocument>
[{"type": "4", "sequence": "1", "filename": "edgar.xml", "description": "PRIMARY DOCUMENT", "secsgml_size_bytes": 4335}]
X0303
4
2010-12-31
0000102212
UNIVEST CORP OF PENNSYLVANIA
UVSP
0001415199
SCHWEITZER JEFFREY M
3964 GOSHEN DRIVE
HARLEYSVILLE
PA
19438
0
1
0
0
EVP & CFO
COMMON
2010-12-31
2011-01-05
4
F
0
102
19.17
D
8953.843
D
COMMON
8953.843
D
VESTED SHARES USED TO PAY TAXES
DOES INCLUDE 537.8430 SHARES ACQUIRED ON OR AFTER AUGUST 15, 1996 THROUGH THE DIVIDEND REINVESTMENT PLAN AND EMPLOYEE STOCK PURCHASE PLAN.
DOES INCLUDE 6,949 SHARES OF RESTRICTED STOCK.
Jeffrey M. Schweitzer
2011-01-04